﻿#include "ssAngle.h"


namespace StarSeeker
{

ssAngle::ssAngle(void)
{
	m_angle = 0.f;
	m_type = AT_RADIAN;
}

ssAngle::ssAngle(AngleType_e type)
{
	m_angle = 0.f;
	m_type = type;
}

ssAngle::~ssAngle(void)
{
}

void ssAngle::UseDegree()
{
	if (m_type==AT_RADIAN)
	{
		m_angle = Math3D::Radian2Degrees(m_angle);
		m_type = AT_DEGREE;
	}
}

StarSeeker::AngleType_e ssAngle::GetType()
{
	return m_type;
}

void ssAngle::UseRadian()
{
	if (m_type==AT_DEGREE)
	{
		m_angle = Math3D::Degrees2Radian(m_angle);
		m_type = AT_RADIAN;
	}
}

ssfloat ssAngle::Radian()
{
	if (m_type==AT_RADIAN)
	{
		return m_angle;
	}
	else
	{
		return Math3D::Degrees2Radian(m_angle);
	}
}

ssfloat ssAngle::Degree()
{
	if (m_type==AT_DEGREE)
	{
		return m_angle;
	}
	else
	{
		return Math3D::Radian2Degrees(m_angle);
	}
}

ssfloat ssAngle::Sin()
{
	if (m_type==AT_RADIAN)
	{
		return Math3D::Sin(m_angle);
	}
	else
	{
		return Math3D::Sin(Math3D::Degrees2Radian(m_angle));
	}
}

ssfloat ssAngle::Cos()
{
	if (m_type==AT_RADIAN)
	{
		return Math3D::Cos(m_angle);
	}
	else
	{
		return Math3D::Cos(Math3D::Degrees2Radian(m_angle));
	}
}

ssfloat ssAngle::Tan()
{
	if (m_type == AT_RADIAN)
	{
		return Math3D::Tan(m_angle);
	}
	else
	{
		return Math3D::Tan(Math3D::Degrees2Radian(m_angle));
	}
}

ssAngle::operator ssfloat*()
{
	return &m_angle;
}

ssAngle::operator ssfloat()
{
	return m_angle;
}

void ssAngle::operator-=(ssfloat fa)
{
	m_angle -= fa;
}

void ssAngle::operator+=(ssfloat fa)
{
	m_angle += fa;
}

void ssAngle::operator=(ssfloat fa)
{
	m_angle = fa;
}

}
